package com.api.utils;

import com.api.db.DBOperation;

public class VerifyMethod {

	DBOperation dbOperation = new DBOperation();

	/**
	 * 断言判断
	 * 
	 * @param Result_expected
	 *            期望值
	 * @param Result_actual
	 *            真实值
	 * @return
	 */
	public String assertResult(String Result_expected, String Result_actual) {
		if (Result_actual.contains(Result_expected)) {
			return "TRUE";
		} else {
			return "FALSE";
		}
	}

	/**
	 * sql断言
	 * 
	 * @param sql
	 * @return
	 */
	public String assertMethod(String sql, String result_actual) {
		String expect_rsult = "";
		String sqlResult = "";
		if (sql.contains(";")) {
			String[] sqls = sql.split(";");
			for (int j = 0; j < sqls.length; j++) {
				sqlResult = dbOperation.getSQLResult(sqls[j]);
				// asser_result = assertResult(sqlResult, result_actual);
				expect_rsult += sqlResult + ";";
			}
			// if (asser_result.contains("FALSE")) {
			// test_result = "FALSE";
			// }
		} else {
			sqlResult = dbOperation.getSQLResult(sql);
			// test_result = verifyResult.assertResult(sqlResult,
			// result_actual);
			expect_rsult = sqlResult;
		}
		return expect_rsult;
	}

}
